<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>03-js的数组.html</title>
</head>
<body>
<!--
        1、定义
        2、取值
        3、遍历
-->

<script>

    // 动态数组 初始化
    var arr = new Array()
    arr[0] = "广州";
    arr[1] = "深圳";
    arr[2] = "香港";

    // 静态数组 初始化
    var arr1 = [
        "张三丰",
        "张翠山",
        "张无忌",
    ]

    console.log(arr1.length)
    console.log(arr1[2])

    //遍历
    for (let i = 0; i < arr1.length; i++) {
        console.log(arr1[i])
    }

    // 遍历数组 for(var i in 数组 ){}   in  拿到下标
    for (var i in arr1) {  // i 是下标，值为0 1 2
        console.log(arr1[i])
    }

    // 遍历数组 for(var temp of 数组 ){}   of  拿到元素
    for (var temp of arr1) { // temp 是数组中的每一个元素
        console.log("数据：",temp)
    }

</script>

</body>
</html>